🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

alasql

Package Overview
Dependencies
Maintainers
2
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alasql

Versatile SQL database for browser or node. Handles relational data and nested JSON (noSQL). Export to and import from Excel, localStorage or IndexedDB

0.3.10
Source
npm
Version published
Weekly downloads
160K
2.13%
Maintainers
2
Weekly downloads
 
Created

What is alasql?

AlaSQL is a JavaScript library that provides a SQL-like syntax for querying and manipulating data in the browser and Node.js. It allows you to perform SQL operations on JavaScript arrays, JSON objects, and other data formats without needing a database server.

What are alasql's main functionalities?

In-memory SQL Database

AlaSQL can be used to perform SQL queries on in-memory data structures like arrays and JSON objects. This example demonstrates selecting records from an array of objects using SQL syntax.

const alasql = require('alasql');
const data = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}];
const result = alasql('SELECT * FROM ? WHERE id = 1', [data]);
console.log(result);

CSV and Excel File Processing

AlaSQL can read and write CSV and Excel files, allowing you to perform SQL operations on data stored in these formats. This example shows how to read data from a CSV file.

alasql('SELECT * FROM CSV("data.csv", {headers:true})', [], function(res) {
  console.log(res);
});

LocalStorage and IndexedDB Support

AlaSQL can store and retrieve data from browser storage solutions like LocalStorage and IndexedDB. This example demonstrates storing a table in LocalStorage.

alasql('CREATE TABLE test (id INT, name STRING)');
alasql('INSERT INTO test VALUES (1, "Alice"), (2, "Bob")');
alasql('SELECT * INTO localStorage FROM test');

Advanced SQL Features

AlaSQL supports advanced SQL features such as GROUP BY, JOIN, and more. This example shows how to use the GROUP BY clause to aggregate data.

alasql('SELECT name, COUNT(*) AS count FROM ? GROUP BY name', [data]);

Other packages similar to alasql

Keywords

sql

FAQs

Package last updated on 06 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts